import React, { Component } from 'react';
import './App.css';
import Nav from './components/common/Nav';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import Index from './components/index/index';
import Classification from './components/classification';
import User from './components/user';
import ShopCart from './components/shopCart';
import Commodity from './components/common/Commodity';
import { Layout } from 'antd';
class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      pageList: [{
        name: "首页",
        icon: "home",
        link: "/index",
        component: Index
      }, {
        name: "分类",
        icon: "bars",
        link: "/classification",
        component: Classification
      }, {
        name: "购物车",
        icon: "shopping-cart",
        link: "/cart",
        component: ShopCart
      }, {
        name: "我的",
        icon: "user",
        link: "/my",
        component: User
      }]
    }
  }
  getPageList() {
    var list = this.state.pageList, pageList = [];
    for (var i = 0, l = list.length; i < l; i++) {
      pageList.push(<Route key={i} path={list[i].link} component={list[i].component} />);
    }
    return pageList;
  }
  render() {
    return (
      <Layout className="App">
        <Router path="/index" component={Index}>
          <Layout className="app-content" >
            {this.getPageList()}
          </Layout>
        </Router>
      </Layout>
    );
  }
}
export default App;
